package SIM_cgi;
require Exporter;
use strict;
use SIM_settings;
use SIM_base;

our @ISA        = ("Exporter");
our @EXPORT     = qw( printMenu printEntry printEntry2 printSeparator testMenuLevel getLongName
                     );
our @VERSION    = 0.01;                 # version number

# include variabeles to be used over the various modules here.
#
my $accessDir = $ENV{'SIM_ACCESSD'};
#my $userLevel = $ENV{'USERLEVEL'};
my $defaultLevel = $ENV{'SIM_DLEVEL'};

my $firstEntry;

sub getLongName {
  # this sub will display the full dns name.
  my $ipAddr = "@_[0]";
  my $ipDir = getIpDir( $ipAddr );
  if ( -f "$ipDir/dnsname.txt" ) {
    my $dnsInfo = catFileLine("$ipDir/dnsname.txt");
    my ( $type, $shortName, $domain ) = split(' ', $dnsInfo);
    return "$shortName.$domain";
  } else {
    return("-");
  }
}

sub testMenuLevel {
  my $options = $_[0];
  my $reqLevel;
  my ( $accOpt1, $accOpt2 ) = split('\+', $options);
  if ( -f "$accessDir/$accOpt1+$accOpt2" ) {
    $reqLevel = catFileLine("$accessDir/$accOpt1+$accOpt2");
  } else {
    $reqLevel = $defaultLevel;
  }
  if ( "$defaultLevel" eq "" ) {
    print("testMenuLevel: no defaultLevel defined.");
  } elsif ( "$reqLevel" > "$userLevel" ) {
    return("sorry ($accOpt1 $accOpt2)");
    print("sorry ($accOpt1 $accOpt2)");
  } else {
    return("oke");
  }
}

sub printSeparator {
  my $info = "@_[0]";
  my $type = "@_[1]";
  my $sepColor = "@_[2]";
  if ( "$type" eq "line" ) {
    print(" $info ");
  } elsif ( "$type" eq "table" ) {
    print("<TR><TD COLSPAN=2><B>$info</B></TD></TR>");
  }
}

sub printEntry {
  my $name = "@_[0]";
  my $description = "@_[1]";
  my $opt1 = "@_[2]";
  my $opt2 = "@_[3]";
  my $level = "@_[4]";
  my $var1 = "@_[5]";
  my $var2 = "@_[6]";
  my $rest = "@_[7]";
  my $type = "@_[8]";
  my $separator = "@_[9]";
  my $color = "@_[10]";
  my $reqLevel;
  if ( -f "$accessDir/$opt1+$opt2" ) {
    $reqLevel = catFileLine("$accessDir/$opt1+$opt2");
  } else {
    $reqLevel = $defaultLevel;
  }
  if ( "$reqLevel" > "$userLevel" ) {
    print("");
  } else {
    if ( "$type" eq "line" ) {
      if ( "$firstEntry" eq "yes" ) {
        $separator = "";
        $firstEntry = "no";
      }
      if ( "$level" eq "1" ) {
        if ( "$opt1" eq "$var1" ) { $color = "red"; }
      } elsif ( "$level" eq "2" ) {
        if ( "$opt1 $opt2" eq "$var1 $var2" ) { $color = "red"; }
      }
      print(" $separator <A HREF=$httpScriptName?$opt1+$opt2+$rest><FONT COLOR=$color>$name</FONT></A>\n");
    } elsif ( "$type" eq "table" ) {
      print("<TR><TD><A HREF=$httpScriptName?$opt1+$opt2+$rest><FONT COLOR=blue>$name</FONT></A></TD>
                 <TD>$description</TD></TR>\n");
    } else {
      print("name=$name, description=$description, opt1=$opt1, opt2=$opt2, level=$level, var1=$var1, var2=$var2, rest=$rest, type=$type, separator=$separator, color=$color<BR>");
    }
  }
}


sub printEntry2 {
  my $name = "@_[0]";
  my $description = "@_[1]";
  my $opt1 = "@_[2]";
  my $var1 = "@_[3]";
  my $varRest = "@_[4]";
  my $type = "@_[5]";
  my $separator = "@_[6]";
  my $color = "@_[7]";
  my $alternative = "@_[8]";
  my $reqLevel;
  my $allOpts = "$var1+$varRest";
  my ( $accOpt1, $accOpt2 ) = split('\+', $allOpts);
  if ( -f "$accessDir/$accOpt1+$accOpt2" ) {
    $reqLevel = catFileLine("$accessDir/$accOpt1+$accOpt2");
  } else {
    $reqLevel = $defaultLevel;
  }
  if ( "$reqLevel" > "$userLevel" ) {
    if ( $alternative ne "" ) {
      # allow to print the text if no update access is possible.
      if ( "$type" eq "line" ) {
        print(" $separator $alternative\n");
      } elsif ( "$type" eq "table" ) {
        print("<TR><TD>$alternative</TD><TD>$description</TD></TR>\n");
      }
    }
  } else {
    if ( "$type" eq "line" ) {
      if ( "$firstEntry" eq "yes" ) {
        $separator = "";
        $firstEntry = "no";
      }
      if ( "$opt1" eq "$var1" ) { $color = "red"; }
      print(" $separator <A HREF=$httpScriptName?$var1+$varRest><FONT COLOR=$color>$name</FONT></A>\n");
    } elsif ( "$type" eq "table" ) {
      print("<TR><TD><A HREF=$httpScriptName?$var1+$varRest><FONT COLOR=blue>$name</FONT></A></TD>
                 <TD>$description</TD></TR>\n");
    } else {
      print("name=$name, description=$description, opt1=$opt1, var1=$var1, varRest=$varRest, type=$type, separator=$separator, color=$color<BR>");
    }
  }
}

sub printMenu {
  my $menuName = "@_[0]";
  my $type = "@_[1]";
  my $var1 = "@_[2]";
  my $var2 = "@_[3]";
  my $var3 = "@_[4]";
  my $var4 = "@_[5]";
  if ( "$accessDir" eq "" ) {
    print("Oops, no accessDir found.");
  } elsif ( "$userLevel" eq "" ) {
    print("Oops, no userlevel found.");
  } elsif ( "$defaultLevel" eq "" ) {
    print("Oops, no defaultLevel found.");
  } elsif ( "$menuName" eq "main" ) {
    my $linkColor = "white";
    $firstEntry = "yes";
#   print("Menu ($accessDir, $userLevel, $defaultLevel, $menuName, $type, $var1, $var2, $var3, $var4)<HR>");
    printEntry("Monitor", "Main status page.", "mon", "none", "1", "$var1", "$var2", "", $type, "", $linkColor);
    printEntry("Info", "Config management location.", "info", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Device", "Device tool.", "dev", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Vendor", "Vendor specific tools.", "vendor", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Map", "Network map.", "map", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Switch", "Switch info new.", "switch2", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
#   printEntry("old", "Switch info.", "switch", "none", "1", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("Dns", "Display dns zone info.", "named", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Graph", "Display device graphs.", "graph", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Subnet", "Subnet definitions (experimental).", "subnet2", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
#   printEntry("old", "Subnet definitions.", "subnet", "none", "1", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("FW-analyser", "Firewall analyser, to display, study and report on firewall configs.", "fwan", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("File", "Edit the various config files.", "file2", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
#   printEntry("old", "Display config and logging files.", "file", "none", "1", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("Extra", "Additional tools and settings.", "extra", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Case", "Tool to log updates, changes and questions.", "case", "none", "1", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Help", "Context sensitive help tool.", "help", "display", "1", "$var1", "$var2", "file+$var1+$var2", $type, "|", $linkColor);

  } elsif ( "$menuName" eq "extra" ) {
    my $linkColor = "black";
    my $sepColor = "#888888";
    printSeparator("Extra",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("VPN", "Configure standardised VPN's.", "extra", "vpn", "2", "$var1", "$var2", "", $type, "", $linkColor);
    printEntry("Starter", "manually start background processes, with screen output.", "extra", "starter", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Reporter", "Run the various reports.", "extra", "reporter", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Syslog", "Run the syslog tool.", "extra", "syslog", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Import", "Run mass imports into the ip database.", "extra", "import", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Seedtool", "Run mass updates / imports besed on seed files.", "extra", "seedTool", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("FixedInfo", "Import data from spreadsheets, etc, to display node info.", "extra", "fixedInfo", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("HealthCheck", "Gather healthcheck, activation / deactivation info.", "extra", "healthCheck", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("TrafficAnalyser", "Import and analyse traffic statistics.", "extra", "trafficAnalyser", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("RemoteExec", "Login to network devices and run various tasks.", "extra", "remoteExec", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("UserMgr", "Manage userid's and groups who have access to Sipman.", "extra", "userManager", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Test", "Test the installation, run commands from the web.", "extra", "tester", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Admin", "Administer Sipman.", "extra", "admin", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printSeparator("Settings",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("user", "Edit user settings.", "extra", "userSettings", "2", "$var1", "$var2", "", $type, "", $linkColor);
    printEntry("admin", "Edit user settings.", "extra", "adminSettings", "2", "$var1", "$var2", "", $type, "/", $linkColor);

  } elsif ( "$menuName" eq "file" ) {
    my $linkColor = "black";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printEntry("Menu", "Display this menu.", "file", "menu", "2", "$var1", "$var2", "menu", $type, "", $linkColor);
    printSeparator("Sipman configs",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Main", "Config files in the main directory (system defaults).", "file", "main-configs", "2", "$var1", "$var2", "list", $type, "", $linkColor);
    printEntry("Shared", "Config files in the shared directory (settings for the system).", "file", "shared-configs", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("Data", "Config files in the domain directory (settings for the view).", "file", "data-configs", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("Zones", "DNS config and zone files.", "file", "zones", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("GraphReport", "Graph reporting files.", "file", "zones", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printSeparator("Logging",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Sipman", "Logging from the various Sipman background processes.", "file", "sipman-log", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("Syslog", "Files in the syslog directory.", "file", "syslog", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("Apache", "Logging files apache deamon.", "file", "apache-log", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printSeparator("Device configs",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Current", "Latest version of the device config files..", "file", "dev-current", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("History", "History of saved device config files.", "file", "dev-history", "2", "$var1", "$var2", "list", $type, "|", $linkColor);
    printEntry("Logs", "Logging of the config save sessions with additional show commands.", "file", "dev-logs", "2", "$var1", "$var2", "list", $type, "|", $linkColor);

  } elsif ( "$menuName" eq "fwan" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printEntry("menu", "Display this menu.", "fwan", "menu", "2", "$var1", "$var2", "$var3", $type, "", $linkColor);
    printEntry("list", "Configure the devices to be analysed.", "fwan", "confList", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("analyse", "Process the config to create the firewall database.", "fwan", "analyse", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printSeparator("nat",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Tunix", "Display the Tunix nat table.", "fwan", "printTunixNat", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Pix-Asa-Fwsm", "Display the Cisco firewall nat table.", "fwan", "printPixNat", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("interfaces", "Display a list of all firewall interfaces.", "fwan", "printInterfaces", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("ips", "Display a list of all ip adresses defined in firewall configs.", "fwan", "printIps", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("hosts", "Display a list of all hosts defined in firewall configs.", "fwan", "printHosts", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("groups", "Display a list of all groups defined in this firewall.", "fwan", "printGroups", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("services", "Display a list of all services defined in this firewall.", "fwan", "printServices", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("rules", "Display a list of all rules defined in this firewall.", "fwan", "printRules", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("members", "Display a list of all rules with members.", "fwan", "printRuleMembers", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("hits", "Display the rulebase and the hits, based on info from the trafficanalyser.", "fwan", "analyseRules", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("analyse", "Reanalyse and display the rulebase and the hits, based on info from the trafficanalyser.", "fwan", "reAnalyseRules", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printSeparator("Report",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Ip", "Generate an ip adress based firewall report.", "fwan", "reportIps", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Policy", "Generate an ip adress based firewall report.", "fwan", "reportPolicy", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);

  } elsif ( "$menuName" eq "mon" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printEntry("Menu", "Display this menu.", "mon", "menu", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Status", "Display the status page, with the nodes down and the syslog summary....", "mon", "statusInfo", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Subnets", "Display the toplevel ip ranges managed and drill down....", "mon", "subnets", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    $firstEntry = "yes";
    my $baseIp;
#   print("  var3=$var3, var4=$var4 ");
    if (( "$var4" eq "" ) or ( "$var4" eq "none" )) {
      my ( $baseInfo, $info, $rest ) = split('\+', $var3);
      $var4 = $info;
      if ( "$baseInfo" eq "ip" ) {
        $baseIp = $info;
      } else {
        $baseIp = $baseInfo;
      }
    } else {
      $baseIp = $var3;
    }
#   print(" baseIp=$baseIp ");
    my $test = testIfIp( $baseIp );
    my ( $ip1, $ip2, $ip3, $ip4 ) = split('\.', $baseIp);
    if (( -d "$SIMparam{'SIMipDatabase'}/$ip1/$ip2/$ip3" ) and ( "$ip3" ne "" )) {
      print(" | ");
      printSeparator("Display",$type, $sepColor);
      printEntry("$ip1.$ip2.$ip3", "Display this subnet list.", "mon", "displaysubnet", "2", "$var1", "$var2", "ip+$ip1.$ip2.$ip3", $type, "|", $linkColor);
      #printEntry("$var4", "Display this subnet list.", "mon", "displaysubnet", "2", "$var1", "$var2", "ip+$var4", $type, "|", $linkColor);
      printEntry("Scan subnet", "Scan the class-C subnet for this node.", "mon", "scansubnet", "2", "$var1", "$var2", "$baseIp", $type, "|", $linkColor);
    }
    printEntry("Search", "Search for names, mac adresses, types etc....", "mon", "searchform", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Log", "Display the various log files.", "mon", "log", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
#   printEntry("Devices", "Display the snmp manageable devices discovered, on a per vendor basis.", "mon", "list", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Add", "Add nodes.", "mon", "addnode", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Ping", "Ping your subnet list.", "mon", "ping", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    if ( "$test" eq "oke" ) {
      print("</FONT></TD></TR>\n<TR BGCOLOR=#EEEEEE><TD COLSPAN=3><FONT COLOR=#666666><CENTER>");
      printMenu("mon-nodestatus","line", $var1, $var2, "$var3");
    }
  } elsif ( "$menuName" eq "dev" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printEntry("Menu", "Display this menu.", "dev", "menu", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Status", "Display the status page, with the nodes down and the syslog summary....", "dev", "statusInfo", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);

  } elsif ( "$menuName" eq "mon-nodestatus" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printEntry("Menu", "Print this menu.", "mon", "nodeMenu", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("NodeInfo", "Display the node status screen.", "mon", "nodestatus", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("Mtr", "Run mtr, a path trace utility.", "mon", "runMtr", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("Ping", "Ping a single node 30 times.", "mon", "pingNode", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("SnmpInfo", "Get realtime snmp based info.", "snmp", "system", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("Map", "Display the map for this node.", "map", "displayNode", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    # get device info
    my ( $ipAddr, $dummy ) = split('\+', $var3);
#   print(" $ipAddr ");
    my $ipDir = getIpDir( $ipAddr );
    my $hostname = catFileLine("$ipDir/hostname.txt");
    my ( $shortName, $dummy ) = split('\.', $hostname);
#   print(" $hostname, $shortName ");
    if ( "$shortName" ne "" ) {
      if ( -d "$SIMparam{'SIMswitchDevices'}/$shortName" ) { 
        printEntry("SwitchInfo", "Switch information.", "switch2", "displaySwitch", "2", "$var1", "$var2", "$shortName", $type, "|", $linkColor);
      }
      my $vendor = catFileLine("$ipDir/vendor");
#     print(" $vendor ");
      if ( -f "$SIMparam{'SIMgraphConfDir'}/$vendor/$shortName/graphinfo.conf" ) {
        printEntry("Graphs", "Device graphs.", "graph", "main", "2", "$var1", "$var2", "$vendor+$shortName", $type, "|", $linkColor);
      }
      # Multiple vendors support (part of the) cisco vendor info.
      if ( $vendor ne "" ) {
        my $found;
        my @numHwInfo = <$SIMparam{'SIMdeviceDir'}/$vendor/$shortName/CW_*>;
        if ( ! @numHwInfo ) {
          my @numHwInfo = <$SIMparam{'SIMdeviceDir'}/$vendor/$shortName/module-*>;
          if ( @numHwInfo ) {
            $found = "yes";
          }
        } else {
          $found = "yes";
        }  
        if ( "$found" eq "yes" ) {
          printEntry("HwReport", "Report hardware info.", "extra", "reporter", "2", "$var1", "$var2", "ciscoDevInfo+$vendor+$shortName", $type, "|", $linkColor);
        }
      }
      if ( -d "$SIMparam{'SIMdevConfigHistory'}/$shortName" ) {
        printEntry("Config", "Device configuration.", "file2", "listDevConfigsHistory", "2", "$var1", "$var2", "name+$shortName", $type, "|", $linkColor);
      }
    }
    printSeparator("Update",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("getInfo", "Update the internal databases for this node.", "mon", "getinfo", "2", "$var1", "$var2", "$var3+$var4", $type, "/", $linkColor);
#   printEntry("int", "Discover the interfaces for this device.", "mon", "discover", "3", "$var1", "$var2", "$var3+$var4+interfaces", $type, "/", $linkColor);
#   printEntry("cdp", "Discover the cdp neighbours for this device.", "mon", "discover", "3", "$var1", "$var2", "$var3+$var4+cdp", $type, "/", $linkColor);
#   printEntry("routers", "Discover the neighbouring routers for this device.", "mon", "discover", "3", "$var1", "$var2", "$var3+$var4+routes", $type, "/", $linkColor);
    printEntry("arp", "Discover other nodes by querying the arp table of this device.", "mon", "discover", "3", "$var1", "$var2", "$var3+$var4+arp", $type, "/", $linkColor);
#   printEntry("graph", "Update the graphing info for this device.", "mon", "confrrd", "2", "$var1", "$var2", "$var3+$var4", $type, "/", $linkColor);
#   printEntry("autoDns", "Configure the dns reccords for this device based on the hostname.", "mon", "confautodns", "2", "$var1", "$var2", "$var3+$var4", $type, "/", $linkColor);
    printEntry("pollSwitch", "Configure the dns reccords for this device based on the hostname.", "mon", "switchinfo", "2", "$var1", "$var2", "$var3+$var4", $type, "/", $linkColor);
    printEntry("Configure", "Configure ip node and dns related info.", "config", "config", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("Whois", "Get whois related info from the internet.", "mon", "whois", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
    printEntry("Add dns prefix", "Configure dns prefixes for ranges of adresses.", "config", "addwhois", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
#   printEntry("Database", "Look at the individual reccords for this node.", "mon", "dispDatabase", "2", "$var1", "$var2", "$var3+$var4", $type, "|", $linkColor);
  } elsif ( "$menuName" eq "file2" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printSeparator("Configs",$type, $sepColor);
    printEntry("main","Config files in the main directory. To adjust settings, add them to the shared or data section.", "file2", "listMainConfig", "2", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("shared","Config files in the shared directory. This directory is used for system wide settings.", "file2", "listSharedConfig", "2", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("data","Config files in the data directory. This directory is used for settings specific for this view.", "file2", "listDomainConfig", "2", "$var1", "$var2", "", $type, "/", $linkColor);
    printEntry("SubnetTemplates","Subnet template files, to automatically assign types to nodes and specify dhcp scopes.", "file2", "listSubnetTemplates", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("DnsPointers","Specify what adress ranges are defined with Pointer reccords.", "file2", "listNamedPtr", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("GraphReport","Graph report files.", "file2", "listGraphReport", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printSeparator("Logging",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Sipman","Logging from the Sipman background processes.", "file2", "listSipmanLog", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Syslog","Syslog system logging.", "file2", "listSyslog", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Apache","Apache webserver logging.", "file2", "listApacheLog", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Dns","Dns config and zone files.", "file2", "listNamed", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Tftp","Tftp directory with IOS and config files.", "file2", "listTftp", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printSeparator("Device configs",$type, $sepColor);
    $firstEntry = "yes";
    printEntry("Current","Current device configs ( the last version saved ).", "file2", "listDevConfigsCurrent", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("History","History device configs.", "file2", "listDevConfigsHistory", "2", "$var1", "$var2", "", $type, "|", $linkColor);
    printEntry("Logs","Logging of the telnet sessions to save the configs (plus aditional show info).", "file2", "listDevConfigsLogs", "2", "$var1", "$var2", "", $type, "|", $linkColor);
  } elsif ( "$menuName" eq "snmp" ) {
    my $linkColor = "#222222";
    my $sepColor = "#888888";
    $firstEntry = "yes";
    printSeparator("General",$type, $sepColor);
    printEntry("menu", "Display this menu.", "snmp", "menu", "2", "$var1", "$var2", "$var3", $type, "", $linkColor);
    printEntry("NodeInfo", "Junp to the node info screen.", "mon", "nodestatus", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printSeparator("Snmp info",$type, $sepColor);
    printEntry("System", "Snmp system info (name, description, contact, etc....", "snmp", "system", "2", "$var1", "$var2", "$var3", $type, " ", $linkColor);
    printEntry("Interfaces", "Physical (layer2) interface info.", "snmp", "interfaces", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("IP", "IP (layer3) interface info.", "snmp", "ip-interfaces", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("Routing", "IP Routing info.", "snmp", "ip-routes", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("Arp", "The arp table.", "snmp", "arpTable", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printSeparator("Vendors",$type, $sepColor);
    printEntry("Aruba", "Aruba wireless info.", "snmp", "aruba", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Brocade", "Brocade san switch info.", "snmp", "brocade", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Cisco", "Cisco works / CDP info.", "snmp", "cisco", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("ModTable", "Cisco module table.", "snmp", "ciscoModuleTable", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("Dot1x", "Cisco dot1x table.", "snmp", "ciscoDot1x", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("Vpn", "Cisco vpn info.", "snmp", "ciscoVpn", "2", "$var1", "$var2", "$var3", $type, "/", $linkColor);
    printEntry("JetDirect", "HP Jet direct printer info.", "snmp", "jetdirect", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Novell", "Novell based info.", "snmp", "novell", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("Windows", "MS Windows based info (type, version, build).", "snmp", "windows-info", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
    printEntry("SnmpWalk", "Walk an snmp tree, may be used for testing snmp oid's.", "snmp", "snmpwalk", "2", "$var1", "$var2", "$var3", $type, "|", $linkColor);
  } else {
    print("menuName: $menuName not coded.");
  } 
}


1;
